package com.mew.chess.core.game.dyj.game;

import java.util.HashMap;
import java.util.Map;


/**游戏管理类  单例 房间列表
 * @author dylin
 */
public class DyjGameManager {

    private int gameId;
    private static DyjGameManager dyjGameManager = new DyjGameManager();
    private final Map<Integer, DyjRoomManager> controllerMap = new HashMap<>(8);

    private DyjGameManager(){
    }

    public static DyjGameManager getInstance() {
        if (dyjGameManager == null) {
            synchronized (DyjGameManager.class) {
                if (dyjGameManager == null) {
                    dyjGameManager = new DyjGameManager();
                }
            }
        }
        return dyjGameManager;
    }


    public void putController(DyjRoomManager controller){
        controllerMap.put(controller.getRoomId(), controller);
    }

    public DyjRoomManager getController(Integer roomId){
        return controllerMap.get(roomId);
    }

    public int getGameId() {
        return gameId;
    }

    public void setGameId(int gameId) {
        this.gameId = gameId;
    }
}
